package com.prs.crm.action.oa;

import java.io.InputStream;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;

import com.prs.crm.context.ToolKits;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.oa.BusinessTravel;
import com.prs.crm.domain.oa.WorkOverTime;
import com.prs.crm.report.ExportConfig;
import com.prs.crm.report.ReportCell;
import com.prs.crm.report.ReportTable;
import com.prs.crm.service.ReportService;
import com.prs.crm.service.hr.PersonService;
import com.prs.crm.service.oa.WorkOverTimeService;

public class WorkOverTimeAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private PaginationSupport pagination;
	private PersonService personService;
	private ReportService reportService;
		
		private InputStream inputStream;
		
		private String contentType;
		
		private String outFilePath;
		
		private String outfileName;
		
		private int exportType;
		private String accepts;
	private WorkOverTime workOverTime;
	private WorkOverTimeService workOverTimeService;
	
	@Action("editWorkOverTime")
	public String editWorkOverTime() {
		
		return SUCCESS;
	}
	@Action("listWorkOverTime")
	public String listWorkOverTime(){
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				WorkOverTime.class);
		criteria.addOrder(Order.desc("recordTime"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.workOverTimeService.listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	@Action(value = "saveWorkOverTime", results = {
			@Result(name = "success", type = "redirect", location = "listWorkOverTime"),
			@Result(name = "error", type = "chain", location = "editWorkOverTime") })
	public String saveWorkOverTime() {
		if(workOverTime.getStartTime().after(workOverTime.getEndTime())){
			this.addActionError("开始时间不能在结束时间之后！");
			return ERROR;
		}
			this.workOverTime.setRecordTime2(new Date());
			this.workOverTimeService.save(workOverTime);
		return SUCCESS;
	}
		public PaginationSupport getPagination() {
			return pagination;
		}
		public void setPagination(PaginationSupport pagination) {
			this.pagination = pagination;
		}
		public PersonService getPersonService() {
			return personService;
		}
		public void setPersonService(PersonService personService) {
			this.personService = personService;
		}
		public ReportService getReportService() {
			return reportService;
		}
		public void setReportService(ReportService reportService) {
			this.reportService = reportService;
		}
		public InputStream getInputStream() {
			return inputStream;
		}
		public void setInputStream(InputStream inputStream) {
			this.inputStream = inputStream;
		}
		public String getContentType() {
			return contentType;
		}
		public void setContentType(String contentType) {
			this.contentType = contentType;
		}
		public String getOutFilePath() {
			return outFilePath;
		}
		public void setOutFilePath(String outFilePath) {
			this.outFilePath = outFilePath;
		}
		public String getOutfileName() {
			return outfileName;
		}
		public void setOutfileName(String outfileName) {
			this.outfileName = outfileName;
		}
		public int getExportType() {
			return exportType;
		}
		public void setExportType(int exportType) {
			this.exportType = exportType;
		}
		public String getAccepts() {
			return accepts;
		}
		public void setAccepts(String accepts) {
			this.accepts = accepts;
		}
		public WorkOverTime getWorkOverTime() {
			return workOverTime;
		}
		public void setWorkOverTime(WorkOverTime workOverTime) {
			this.workOverTime = workOverTime;
		}
		public WorkOverTimeService getWorkOverTimeService() {
			return workOverTimeService;
		}
		public void setWorkOverTimeService(WorkOverTimeService workOverTimeService) {
			this.workOverTimeService = workOverTimeService;
		}
		
}
